/*  * To change this template, choose Tools | Templates  * and open the template in the editor.  */
package haw.pr2.A2a.implementations;

import haw.pr2.A2a.interfaces.Acc;
import static haw.pr2.A2a.implementations.UtilityclassValues.*;
import haw.pr2.A2a.interfaces.Speed;
import haw.pr2.A2a.interfaces.TimeDiff;

/**  *  * @author Fabian Heidorn, Alexander Kaack  */
class AccInMs extends AbstractScalar<Acc> implements Acc,Comparable<Acc> {
    
    private final double accInMs;

    AccInMs(double accInMs) {
        this.accInMs = accInMs;
    }
    
    

    @Override
    public Acc inverse() {
        return new AccInMs(-this.ms2());
    }

    @Override
    public Acc add(Acc value) {
        return new AccInMs(this.ms2() + value.ms2());
    }

    @Override
    public Acc sub(Acc value) {
        return new AccInMs(this.ms2() - value.ms2());
    }

    @Override
    public Acc mul(double value) {
        return new AccInMs(this.ms2() * value);
    }

    @Override
    public Acc div(double value) {
        return new AccInMs(this.ms2() / value);
    }

    @Override
    public double div(Acc value) {
        return this.ms2() / value.ms2();
    }

    @Override
    public boolean isZero() {
        return this.equals(ZERO_ACC);
    }

    @Override
    public boolean isValid() {
        return true;
    }

    @Override
    public double ms2() {
        return this.accInMs;
    }

    // @Override
    public static Acc valueOf(double value) {
        return new AccInMs(value);
    }

    @Override
    public double toDouble() {
        return this.ms2();
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (int) (Double.doubleToLongBits(this.accInMs) ^ (Double.doubleToLongBits(this.accInMs) >>> 32));
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (!(obj instanceof AccInMs)) return false;
        return this.compareTo((AccInMs)obj) == 0;
    }
    
    @Override
    public int compareTo(Acc a) {
        return Double.compare(this.ms2() , a.ms2());
    }

    @Override
    public Speed mulT(TimeDiff td) {
        return new SpeedInMpS(this.mul(td.s()).ms2());
    }
    
}
